package com.htzos.admin.ac.controller;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.htzos.admin.ac.bean.AcMsgreadlogBase;
import com.htzos.admin.ac.service.AcMsgreadlogBaseService;
import com.htzos.base.parent.ctrl.BaseController;
import com.htzos.common.tool.ExtQueryBean;

@Controller
@RequestMapping("/acMsgreadlogBase")
public class AcMsgreadlogBaseController extends BaseController{

    @Resource
    AcMsgreadlogBaseService acMsgreadlogBaseService;

    @RequestMapping("/list")
    public ModelAndView list(HttpServletRequest request,AcMsgreadlogBase condition, ExtQueryBean extQuery) {
        if(extQuery.getPageNum() == null) {
            extQuery.setSize(10);
            extQuery.setPageNum(1);
        }
        Integer messageId=Integer.valueOf(request.getParameter("messageId"));
        condition.setMessageId(messageId);
        extQuery.setAppendSql(" order by readtime desc ");
        extQuery.setTotal(acMsgreadlogBaseService.acMsgreadlogBaseTotal(condition, extQuery));
        List<AcMsgreadlogBase> list= acMsgreadlogBaseService.acMsgreadlogBaseList(condition, extQuery);
        request.setAttribute("list", list);
        request.setAttribute("condition", condition);
        request.setAttribute("extQuery", extQuery);
        request.getSession(true).setAttribute("conditionStr", condition);
        request.getSession(true).setAttribute("extQueryStr", extQuery);
        return new ModelAndView("admin/ac/acMsgreadlogBaseList");
    }

    @RequestMapping("/update")
    public ModelAndView update(HttpServletRequest request, AcMsgreadlogBase acMsgreadlogBase) {
        acMsgreadlogBaseService.acMsgreadlogBaseUpdate(acMsgreadlogBase);
        return new ModelAndView(new RedirectView("list"), getSessionQueryString(request));
    }

    @RequestMapping("/updatePage")
    public String updatePage(HttpServletRequest request, String id) {
        AcMsgreadlogBase acMsgreadlogBase = acMsgreadlogBaseService.acMsgreadlogBaseGet(id);
        request.setAttribute("acMsgreadlogBase", acMsgreadlogBase);
        return "admin/ac/acMsgreadlogBaseUpdate";
    }

    @RequestMapping("/insert")
    public ModelAndView insert(HttpServletRequest request, AcMsgreadlogBase acMsgreadlogBase) {
        acMsgreadlogBaseService.acMsgreadlogBaseInsert(acMsgreadlogBase);
        return new ModelAndView(new RedirectView("list"), getSessionQueryString(request));
    }
    @RequestMapping("/addPage")
    public String addPage() {
        return "admin/ac/acMsgreadlogBaseAdd";
    }

    @RequestMapping("/delete")
    public ModelAndView delete(HttpServletRequest request, AcMsgreadlogBase acMsgreadlogBase) {
        acMsgreadlogBaseService.acMsgreadlogBaseDelete(acMsgreadlogBase);
         return new ModelAndView(new RedirectView("list"), getSessionQueryString(request));
    }
}